<%# present @timecard do |timecard_presenter| %>
<% content_for :sidebar do %>
  <%= sidebar_button_link 'Return to Timecards', timecards_path %>
  <%= sidebar_button_link 'Edit Timecard', edit_timecard_path(@timecard) if can? :edit, @timecard %>
<% end %>

<p>
  <b>Person:</b><%= link_to @timecard.person.fullname, @timecard.person %>
</p>

<p>
  <b>Status:</b><span id='<%= "js-timecard-status-id-#{@timecard.id}" %>'><%= @timecard.status %></span>
</p>

<p>
  <b>Start</b>
  <%= @timecard.start_time.strftime("%B %e, %Y %H:%M") if @timecard.start_time %>
</p>

<p>
  <b>End</b>
  <%= l @timecard.end_time, :format => :long if @timecard.end_time %>
</p>

<p>
  <b>Duration:</b>  <%= @timecard.duration %>
</p>
<% if (can? :verify, @timecard) && @timecard.status == "Unverified" %>
  <%= button_to 'Verify',
    timecard_verify_path(@timecard),
    form_class: 'timecard-verify',
    params: { id: @timecard.id },
    id: "js-timecard-verify-btn-id-#{@timecard.id}",
    class: 'js-timecard-verify-btn btn btn-xs btn-success'
  %>
<% end %>

<table class="generic-datatable table table-striped table-bordered" >
  <caption>
    <h3 class="data-table-title">Concurrent Events</h3>
  </caption>
  <thead>
    <tr>
      <th>Title</th>
      <th>Location</th>
      <th>Start time</th>
      <th>Start time</th>
      <th>End time</th>
      <th>End time</th>
      <th>Duration</th>
      <th>Status</th>
      <th></th>
    </tr>
  </thead>
  <tbody>
    <% @timecard.concurrent_events.each do |e| %>
      <tr class='<%= column_color_class(e) %>'>
        <td><%= link_to e.title, e %></td>
        <td><%= e.location %></td>
        <td><%= e.start_time %></td>
        <td><time>
          <%= e.start_time.strftime('%a, %b %d, %y %k:%M') if e.start_time  %>
        </time></td>
        <td><%= e.end_time %></td>
        <td><time>
          <%= e.end_time.strftime('%a, %b %d, %y %k:%M') if e.end_time  %>
        </time></td>
        <td><%= e.duration %></td>
        <td><%= e.status %></td>
        <td><%= table_button_link 'Edit', edit_event_path(e) unless cannot? :update, e %></td>
      </tr>
    <% end %>
  </tbody>
</table>

<p>
  Created <%= @timecard.created_at %><br/>
  Last Modified <%= @timecard.updated_at %><br/>
  Last Editor <%= @last_editor %>
</p>
